package com.forum.controller;

import com.forum.pojo.Message;
import com.forum.pojo.User;
import com.forum.service.MessageService;
import com.forum.service.UserService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/page")
public class pageController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/adminLogin",produces = "text/html;charset=UTF-8")
    public String adminlogin(){
        return "administratorlogin";
    }

    @RequestMapping(value = "/userLogin",produces = "text/html;charset=UTF-8")
    public String userlogin(){
        return "login_test";
    }

    @RequestMapping(value = "/userRegister",produces = "text/html;charset=UTF-8")
    public String toregister(){
        return "regist";
    }

    @RequestMapping(value = "/userIndex",produces = "text/html;charset=UTF-8")
    public String userIndex(){
        return "userindex";
    }

    @RequestMapping(value = "/sendMessage",produces = "text/html;charset=UTF-8")
    public String sendMessage(){
        return "sendMessage";
    }

    @RequestMapping(value = "/message",produces = "text/html;charset=UTF-8")
    public String message(){
        return "message";
    }

    @RequestMapping(value = "/update",produces = "text/html;charset=UTF-8")
    public String update(Model model,String userID){
        User u = userService.findUserById(userID);
        model.addAttribute("userdata",u);
        return "update";
    }

    @RequestMapping(value = "/insert",produces = "text/html;charset=UTF-8")
    public String insert(){
        return "insert";
    }

    @RequestMapping(value = "/index",produces = "text/html;charset=UTF-8")
    public String index(){
        return "index";
    }
    @RequestMapping(value = "/PersonInfo",produces = "text/html;charset=UTF-8")
    public String PersonInfo(){
        return "PersonInfo";
    }
    @RequestMapping(value = "/admin",produces = "text/html;charset=UTF-8")
    public String admin(){
        return "administrator";
    }

    @RequestMapping(value = "/workbench",produces = "text/html;charset=UTF-8")
    public String workbench(){
        return "workbench";
    }
    @RequestMapping(value = "/workbench2",produces = "text/html;charset=UTF-8")
    public String workbench2(){
        return "workbench2";
    }


}
